package com.bkfm.framework.sys.entity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bkfm.framework.core.constants.BkfmConstants;
import com.bkfm.framework.sys.entity.BkfmUsers;

import net.sf.json.JSONObject;


/**
 *
 * @平台：FAMSUN统一开发平台
 * @文件名称：CurrentUser.java
 * @文件描述：基类用户
 * @author xq
 * @日期：2017年11月20日下午4:32:21
 *
 */
public class CurrentUser implements Serializable{

	private static final long serialVersionUID = 1L;
	

	/**
	 * 国际化语言
	 */
	private String nativeLanguage;

	/**
	 *用户
	 */
	private BkfmUsers user;

	/**
	 * 用户角色
	 */
	private List<BkfmRoles> roleList;

	/**
	 * 用户菜单
	 */
	private List<BkfmMenu> menuList;
	
	/**
	 * 桌面菜单
	 */
	private List<BkfmMenu> deskTopMenuList;

	/**
	 * 用户所属部门
	 */
	private List<BkfmUserOrgs> deptList;
	
	/**
	 * 默认所属部门
	 */
	private BkfmUserOrgs defaultDept;
	
	/**
	 * 是否管理员用户,默认非管理员
	 */
	private boolean isSuperAdminUser = false;
	
	/**
	 * 登录扩展接口用户自定义信息
	 */
	private Map<String,Object> customMap = new HashMap<String,Object>();
	
	/**
	 * 主题路径
	 */
	private BkfmThemes bkfmThemes;

	public String getNativeLanguage() {
		return nativeLanguage;
	}

	public void setNativeLanguage(String nativeLanguage) {
		this.nativeLanguage = nativeLanguage;
	}

	public BkfmUsers getUser() {
		return user;
	}

	public void setUser(BkfmUsers user) {
		this.user = user;
	}

	public List<BkfmRoles> getRoleList() {
		return roleList;
	}

	public void setRoleList(List<BkfmRoles> roleList) {
		this.roleList = roleList;
		//设置是否为管理员
		for(BkfmRoles role : roleList) {
			if(role.getROLE_CODE().equals(BkfmConstants.ADMINISTRATOR)) {
				this.setSuperAdminUser(true);
				break;
			}
		}
	}

	public List<BkfmMenu> getMenuList() {
		return menuList;
	}

	public void setMenuList(List<BkfmMenu> menuList) {
		this.menuList = menuList;
	}

	public List<BkfmUserOrgs> getDeptList() {
		return deptList;
	}

	public void setDeptList(List<BkfmUserOrgs> deptList) {
		this.deptList = deptList;
		//设置默认部门
		for(BkfmUserOrgs userDept : deptList) {
			if(userDept.getIs_default().equals(BkfmConstants.YES)) {
				this.setDefaultDept(userDept);
				break;
			}
		}
	}

	public Map<String, Object> getCustomMap() {
		return customMap;
	}

	public void setCustomMap(Map<String, Object> customMap) {
		this.customMap = customMap;
	}

	public boolean isSuperAdminUser() {
		return isSuperAdminUser;
	}

	public void setSuperAdminUser(boolean isSuperAdminUser) {
		this.isSuperAdminUser = isSuperAdminUser;
	}

	public BkfmUserOrgs getDefaultDept() {
		return defaultDept;
	}

	public void setDefaultDept(BkfmUserOrgs defaultDept) {
		this.defaultDept = defaultDept;
	}
	
	public BkfmThemes getBkfmThemes() {
		return bkfmThemes;
	}

	public void setBkfmThemes(BkfmThemes bkfmThemes) {
		this.bkfmThemes = bkfmThemes;
	}

	@Override
	public String toString() {
		JSONObject jsonStr = new JSONObject();
		jsonStr.put("nativeLanguage", this.nativeLanguage);
		jsonStr.put("user", this.user);
		//jsonStr.put("roleList", this.roleList);
		//jsonStr.put("menuList", this.menuList);
		//jsonStr.put("deptList", this.deptList);
		jsonStr.put("defaultDept", this.defaultDept);
		jsonStr.put("isSuperAdminUser", this.isSuperAdminUser);
		jsonStr.put("customMap", this.customMap);
		return jsonStr.toString();
	}
}
